package com.abel.roommanager.service.imp;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.abel.roommanager.mapper.RepairMapper;
import com.abel.roommanager.mapper.RoomMapper;
import com.abel.roommanager.pojo.Repair;
import com.abel.roommanager.pojo.Room;
import com.abel.roommanager.service.RepairService;
@Service
public class RepairServiceImp implements RepairService{
	@Resource
   private RepairMapper repairMapper;
	@Resource
	private RoomMapper roomMapper;
	@Override
	public List<Repair> findLossByRid(int roomno) {
		
		return repairMapper.findLossByRid(roomno);
	}
	@Override
	public int addRepair(Repair repair) {
//		通过房间编号查询房间
		Room room=roomMapper.findRoomById(repair.getRoomno());
		if(room.getLivenumber()<=0){
			return -1;//表示当前房间无人居住不能添加损坏记录
		}
		return repairMapper.addRepair(repair);
	}
	@Override
	public int repairDevice(int id) {
		return repairMapper.repairDevice(id);
		
	}

}
